export class TCanvasTextureEditor {
    canvas: HTMLCanvasElement
    constructor(width: number = 512, height: number = 512, bgColor: string = 'rgb(255,255,255)'){
        this.canvas = document.createElement("canvas")
        this.canvas.width = width
        this.canvas.height = height
        this.canvas.style.backgroundColor = bgColor
    }
    draw(func: (ctx: CanvasRenderingContext2D)=>void): this{
        let ctx = this.canvas.getContext("2d")
        if(ctx){
            func(ctx)
        }else{
            console.log("your browser can not support canvas2d")
        }
        return this
    }
    preview(): this{
        const canvas = this.canvas
        canvas.style.position = 'fixed'
        canvas.style.left = '25%'
        canvas.style.top = '25%'
        document.body.appendChild(canvas)
        return this
    }
}